package com.intel.surface;

import com.google.gson.Gson;
import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.FileInputStream;

public class ProgramStater {
    public static void main(String[] args) {
        loadConfig();
        DeviceListFrame deviceListFrame = new DeviceListFrame();
        deviceListFrame.setVisible(true);

    }

    private static void loadConfig() {
        File config = new File("config/config.json");
        SettingConfig settingConfig = null;
        if (config.exists()) {
            Gson gson = new Gson();
            try {
                FileInputStream in = new FileInputStream("config/config.json");
                settingConfig = gson.fromJson(IOUtils.toString(in, "UTF-8"), SettingConfig.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            settingConfig = new SettingConfig();
            settingConfig.setServerAddress("localhost");
            settingConfig.setServerPort("18788");
        }
        SettingConfig.setConfig(settingConfig);
    }
}
